-
Notifications
You must be signed in to change notification settings - Fork 9.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add eventbus to cloudwatch event rule #15727
Conversation
@gdavison Thanks for working on this. We created a fork based on 3.12.0, merged in your changes from this PR (and provider "aws" {
version = "3.12.0-with-15727-and-15799"
region = "eu-west-1"
}
data "aws_caller_identity" "current" {}
resource "aws_cloudwatch_event_bus" "test" {
name = "test-awendt"
}
resource "aws_cloudwatch_event_rule" "non-default-bus" {
event_bus_name = aws_cloudwatch_event_bus.test.name
description = "Filters all events from EventBridge Bus ${aws_cloudwatch_event_bus.test.name}"
is_enabled = false
name = "test-rule"
event_pattern = jsonencode(
{
account = [
data.aws_caller_identity.current.account_id,
]
}
)
} Steps to reproduce
This last step fails with:
Can you reproduce this? What could be causing this behavior? |
@gdavison Some more context: We noticed Terraform wanted to create a resource that was already existing. It seems both |
Hi @awendt. When importing a rule for a non-default bus, the format of the import id is /, and it assumes that the bus is the default bus if only the is passed. In the example you posted, you'd need to call |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One small question, otherwise LGTM 🚀
Output from acceptance testing:
--- PASS: TestAccAWSCloudWatchEventRule_ScheduleAndPattern (34.58s)
--- PASS: TestAccAWSCloudWatchEventRule_Name_Generated (38.15s)
--- PASS: TestAccAWSCloudWatchEventRule_NamePrefix (39.13s)
--- PASS: TestAccAWSCloudWatchEventRule_role (53.03s)
--- PASS: TestAccAWSCloudWatchEventRule_pattern (56.78s)
--- PASS: TestAccAWSCloudWatchEventRule_description (58.19s)
--- PASS: TestAccAWSCloudWatchEventRule_IsEnabled (68.64s)
--- PASS: TestAccAWSCloudWatchEventRule_basic (71.60s)
--- PASS: TestAccAWSCloudWatchEventRule_EventBusName (72.20s)
--- PASS: TestAccAWSCloudWatchEventRule_tags (82.68s)
} else { | ||
return nil, errors.New("schedule_expression can only be set on the default event bus") | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Is the API error not clear in this case?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is short-circuiting the API call. I would have set it as a ValidateFunc
if they supported cross-attribute validation
@gdavison Thanks for catching this, I can confirm the import works as you described. 🎉 I was also able to track down the root cause why refresh isn't working for us, and I believe we can just re-import the resources and all will be good. |
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thanks! |
Completes work from #12886 to add custom event buses to CloudWatch Events rules.
Closes #12886
Relates #9330
Release note for CHANGELOG:
Output from acceptance testing: